export function debounce<T>(handle: Function, timer: number) {
    let timeOld = Date.now();
    return function(arg: T) {
        let timeNow = Date.now();
        if (timeNow - timeOld >= timer) {
            handle(arg);
            timeOld = Date.now();
        } else {
            setTimeout(() => {
                handle(arg);
                timeOld = Date.now();
            }, timeNow - timeOld);
        }
    }
}